<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>


<html>
<head>
</head>

<body>
    <h1><a rel="permalink" href="#">${topic.subject}</a></h1>
    <p class="info">
        <fmt:formatDate value="${topic.editdate.time}" type="both" pattern="yyyy-MM-dd HH:mm:ss" var="topic_edittime"/>
        <spring:message code="message.topic_author_edited_at" arguments="/author/${topic.poster.id},${topic.poster.name},${topic_edittime}"/>
    </p>
    <c:if test="${not empty topic.tags}">
    <dl class="tags">
        <dt class="forum"><spring:message code="message.communities"/></dt>
        <dd><a id="${topic.forumId}" name="${forumName}" href="<spring:url value="/forums/${topic.forumId}"/>">${forumName}</a></dd>
        <dt><spring:message code="message.categories"/></dt>
        <c:forEach var="tag" items="${topic.tags}">
        <dd><a id="${tag.id}" name="${tag.name}" href="<spring:url value="/tags/${tag.id}"/>">${tag.name}</a>&nbsp</dd>
        </c:forEach>
    </dl>
    </c:if>
    ${topic.content}
    <div class="comments-header">
        <h3>
        <span id="comments-number"><c:if test="${not empty posts}">${posts.totalPages}</c:if></span><spring:message code="message.categories"/>
        </h3>
        <p>
        <span id="watch">
        <a class="comment-watch" href="#"><spring:message code="message.watch_this_comment"/></a>
        </span>
        <a class="comment-reply" href="<spring:url value="/topics/${topic.id}/reply"/>"><spring:message code="message.discuss"/></a>
        </p>
    </div>
    <span style="display: none;" id="newMessage">
    </span>
    <div class="comments-sort">
        <span id="comments-sort">
        <a href="#" class="comment-sort-desc"><spring:message code="message.sort_by_date"/></a>
        </span>
    </div>
    <ol class="comments">
        <c:if test="${not empty posts.content}">
        <c:forEach var="post" items="${posts.content}">
        <li id="comment-${post.id}">
            <a name="view_${post.id}"></a>
            <div class="comment-header">
                <p class="comment-top">
                <a href="#" style="position: relative;"><spring:message code="message.return_top"/></a>
                </p>
                <div>
                    <p class="comment-author">
                        <fmt:formatDate value="${post.createdate.time}" type="both" pattern="yyyy-MM-dd HH:mm:ss" var="posttime"/>
                        <spring:message code="message.comment_author" arguments="${posttime},${post.poster.username}"/>
                    </p>
                </div>
            </div>
            <div id="body_${post.id}">
                <p>
                <span id="quote_${post.id}">
                ${post.content}
                </span>
                </p>
            </div>
            <p class="comment-footer">
            <a href="<spring:url value="/posts/${post.id}/quote"/>" class="comment-reply"><spring:message code="message.reply"/></a>
            </p>
        </li>
        </c:forEach>
        </c:if>
    </ol>
</body>
</html>